/**
 * Created by 沈小鱼 on 2016/8/6.
 */
$(function(){
    $(document).ready(function(){
        $(".contact-box").each(function(){
            animationHover(this,"pulse")
        });
    });
    $(window).load(function(){
        photos = $('img');
        photos.each(function(index,value){
            var img = new Image();
            img.src = value.src;
            img.onerror = function(){
                value.src = '/marriage/admin/web/photo/users/user-default.jpg';
                $(value).parents('a')[0].href='/marriage/admin/web/photo/users/user-default.jpg';
            };
        });
        $('#userdetail-md_hascar').attr('value','无');
        $('#userdetail-md_loan').attr('value','无');
        $('#userdetail-md_isowner').attr('value','无');
        var mydate = new Date();
        var year = mydate.getFullYear(); //获取完整的年份(4位,1970-????)
        var mon = mydate.getMonth(); //获取当前月份(0-11,0代表1月),
        if(mon<9){
            mon = '0'+(mon+1);
        }else{
            mon = mon+1
        }
        $('#userinfo-mi_birth').val( year+'年'+mon+'月');
    });
    $('[name="sex"],[name="edu"],[name="province"],[name="city"],[name="district"]').change(function(){
        searchUser(1);
    });
    $('#searchIsowner,#searchHascar').click(function(){
        searchUser(1);
    });
    $('#searchminage,#searchmaxage').blur(function(){
        min = $('#searchminage').val();
        max = $('#searchmaxage').val();
        if(min>max&&min!=''&&max!=''){
            layer.alert('最小年龄不能超过最大年龄');
            return false;
        }else {
            searchUser(1);
        }
    });
    $('#searchUser').click(function () {
        searchUser(1);
    })
    $('#emptySearch').click(function(){
        $('#searchName').val('');
        $('#searchPhone').val('');
        $('#searchQQ').val('');
        $('#searchCard').val('');
        $('#searchminage').val('');
        $('#searchmaxage').val('');
        $('#searchIsowner').removeAttr('checked');
        $('#searchHascar').removeAttr('checked');
        $('[name="sex"]').val(0);
        $('[name="province"]').val(0);
        $('[name="city"]').val(0);
        $('[name="district"]').val(0);
        $('[name="edu"]').val(0);
        searchUser(1);
    });
    $('#user_info input[id="userinfo-mi_birth"]').change(function(){
        var str = this.value.substr(0,4)*1;
        var arr = ['猴','鸡','狗','猪','鼠','牛','虎','兔','龙','蛇','马','羊'];
        index = str%12
        $('#userinfo-mi_zodiac').val(arr[index]);
    });
    $('.table-stripped b[id="name"]').click(function(){
        //alert(111);
        //return false;
        user_id = $(this).parents('tr').find('#mi_id').text();
        $('#user_detail'+user_id).fadeToggle();
    });
    $('#info_privince').change(function(){
        csrfToken = $('meta[name="csrf-token"]').attr("content");
        privince_id = $('#info_privince option:selected').val();
        city = $('#info_city');
        city_html = '';
        $.ajax({
            statusCode: {
                302: function() {
                    layer.alert('登录信息已过期，请重新登录',{icon: 1,closeBtn:0},function(index){
                        layer.close(index);
                        window.top.location.href='/marriage/admin/web/index.php/';
                        return false;
                    });
                }
            }
        });
        $.post('/marriage/admin/web/index.php/user/areachange',{
            '_marriage-admin':csrfToken,
            'area_id':privince_id,
            'level':1,
        },function(data){
            if(data.status == '302'){
                layer.alert('登录信息已过期，请重新登录',{icon: 0,closeBtn:0},function(){
                    window.top.location.href='/marriage/admin/web/index.php/';
                });
                return false;
            }else if(data.status == '200'){
                city.empty();
                res = data.data;
                cities = res.cities;
                $.each(cities,function(index,item){
                    city_html+='<option value="'+index+'">'+item+'</option>';
                });
                city.append(city_html);
                return false;
            }else{
                ShowMessage(data.status,data.message);
                $(this).val('320000');
                return false;
            }
        },'json');
    });
    $('#extra_privince').change(function(){
        csrfToken = $('meta[name="csrf-token"]').attr("content");
        privince_id = $('#extra_privince option:selected').val();
        city = $('#extra_city');
        city_html = '';
        district = $('#extra_district');
        district_html = '';
        $.ajax({
            statusCode: {
                302: function() {
                    layer.alert('登录信息已过期，请重新登录',{icon: 1},function(index){
                        layer.close(index);
                        window.top.location.href='/marriage/admin/web/index.php/';
                        return false;
                    });
                }
            }
        });
        $.post('/marriage/admin/web/index.php/user/areachange',{
            '_marriage-admin':csrfToken,
            'area_id':privince_id,
            'level':1,
        },function(data){
            if(data.status == '302'){
                layer.alert('登录信息已过期，请重新登录',{icon: 0},function(){
                    window.top.location.href='/marriage/admin/web/index.php/';
                });
                return false;
            }else if(data.status == '200'){
                city.empty();
                district.empty();
                res = data.data;
                cities = res.cities;
                districts = res.districts;
                $.each(cities,function(index,item){
                    city_html+='<option value="'+index+'">'+item+'</option>';
                });
                $.each(districts,function(index,item){
                    district_html+='<option value="'+index+'">'+item+'</option>';
                });
                city.append(city_html);
                district.append(district_html);
                return false;
            }else{
                ShowMessage(data.status,data.message);
                $(this).val('320000');
                return false;
            }
        },'json');
    });
    $('#extra_city').change(function(){
        csrfToken = $('meta[name="csrf-token"]').attr("content");
        city_id = $('#extra_city option:selected').val();
        district = $('#extra_district');
        district_html = '';
        $.ajax({
            statusCode: {
                302: function() {
                    layer.alert('登录信息已过期，请重新登录',{icon: 1,closeBtn:0},function(index){
                        layer.close(index);
                        window.top.location.href='/marriage/admin/web/index.php/'
                        return false;
                    });
                }
            }
        });
        $.post('/marriage/admin/web/index.php/user/areachange',{
            '_marriage-admin':csrfToken,
            'area_id':city_id,
            'level':2,
        },function(data){
            if(data.status == '302'){
                layer.alert('登录信息已过期，请重新登录',{icon: 0,closeBtn:0},function(){
                    window.top.location.href='/marriage/admin/web/index.php/';
                });
                return false;
            }else if(data.status == '200'){
                district.empty();
                res = data.data;
                districts = res.districts;
                $.each(districts,function(index,item){
                    district_html+='<option value="'+index+'">'+item+'</option>';
                });
                district.append(district_html);
                return false;
            }else{
                ShowMessage(data.status,data.message);
                $(this).val('320400');
                return false;
            }
        },'json');
    });
    $('#detail_privince').change(function(){
            csrfToken = $('meta[name="csrf-token"]').attr("content");
            privince_id = $('#detail_privince option:selected').val();
            city = $('#detail_city');
            city_html = '';
            district = $('#detail_district');
            district_html = '';
            $.ajax({
                statusCode: {
                    302: function() {
                        layer.alert('登录信息已过期，请重新登录',{icon: 1,closeBtn:0},function(index){
                            layer.close(index);
                            window.top.location.href='/marriage/admin/web/index.php/';
                            return false;
                        });
                    }
                }
            });
            $.post('/marriage/admin/web/index.php/user/areachange',{
                '_marriage-admin':csrfToken,
                'area_id':privince_id,
                'level':1,
            },function(data){
                if(data.status == '302'){
                    layer.alert('登录信息已过期，请重新登录',{icon: 0,closeBtn:0},function(){
                        window.top.location.href='/marriage/admin/web/index.php/';
                    });
                    return false;
                }else if(data.status == '200'){
                    city.empty();
                    district.empty();
                    res = data.data;
                    cities = res.cities;
                    districts = res.districts;
                    $.each(cities,function(index,item){
                        city_html+='<option value="'+index+'">'+item+'</option>';
                    });
                    $.each(districts,function(index,item){
                        district_html+='<option value="'+index+'">'+item+'</option>';
                    });
                    city.append(city_html);
                    district.append(district_html);
                    return false;
                }else{
                    ShowMessage(data.status,data.message);
                    $(this).val('320000');
                    return false;
                }
            },'json');
        });
    $('#detail_city').change(function(){
        csrfToken = $('meta[name="csrf-token"]').attr("content");
        city_id = $('#detail_city option:selected').val();
        district = $('#detail_district');
        district_html = '';
        $.ajax({
            statusCode: {
                302: function() {
                    layer.alert('登录信息已过期，请重新登录',{icon: 1,closeBtn:0},function(index){
                        layer.close(index);
                        window.top.location.href='/marriage/admin/web/index.php/';
                        return false;
                    });
                }
            }
        });
        $.post('/marriage/admin/web/index.php/user/areachange',{
            '_marriage-admin':csrfToken,
            'area_id':city_id,
            'level':2,
        },function(data){
            if(data.status == '302'){
                layer.alert('登录信息已过期，请重新登录',{icon: 0,closeBtn:0},function(){
                    window.top.location.href='/marriage/admin/web/index.php/';
                });
                return false;
            }else if(data.status == '200'){
                district.empty();
                res = data.data;
                districts = res.districts;
                $.each(districts,function(index,item){
                    district_html+='<option value="'+index+'">'+item+'</option>';
                });
                district.append(district_html);
                return false;
            }else{
                ShowMessage(data.status,data.message);
                $(this).val('320400');
                return false;
            }
        },'json');
    });
    $('#userdetail-md_marry').change(function(){
        $('#md_despid').hide();
        $('#md_child').hide();
        $('#md_child_belong').hide();
        $("#userdetail-md_despid").val('');
        $("#userdetail-md_child_belong").val('');
        $('#md_child_belong').val('');
        $('input:radio[name="UserDetail[md_child]"]').attr('checked',false);
        if($(this).val()=='离异'){
            $('#md_despid').show();
            $('#md_child').show();
        }else if($(this).val()=='丧偶'){
            $('#md_child').show();
        }
    });
    $('input:radio[name="UserDetail[md_child]"]').change(function(){
        $('#md_child_belong').hide();
        $("#userdetail-md_child_belong").val('');
        if($(this).val()=='有'){
            $('#md_child_belong').show();
        }
    });
    $('#md_isowner').click(function(){
        $('#userdetail-md_isowner').val('无');
        $('#house_location').hide();
        $('#house_address').hide();
        $('#house_area').hide();
        $('#detail_privince').val('0');
        $('#detail_city').empty();
        $('#detail_district').empty();
        $('#detail_city').html('<option value="0" selected>请先选择省份</option>');
        $('#detail_district').html('<option value="0" selected>请先选择省份</option>');
        $('#userdetail-md_house_area').val('');
        $('#userdetail-md_house_address').val('');
        if($(this).is(':checked')){
            $('#userdetail-md_isowner').val('有');
            $('#house_location').show();
            $('#house_address').show();
            $('#house_area').show();
        }
    });
    $('#md_loan').click(function(){
        $('#userdetail-md_loan').val('无');
        if($(this).is(':checked')){
            $('#userdetail-md_loan').val('有');
        }
    });
    $('#md_hascar').click(function(){
        $('#userdetail-md_hascar').val('无');
        $('#car_type').hide();
        $('#userdetail-md_cartype').val('');
        if($(this).is(':checked')){
            $('#userdetail-md_hascar').val('有');
            $('#car_type').show();
        }
    });
    $("tr").find('#user_del').click(function(){
        mi_id = $(this).parents('tr').find('#mi_id');
        csrfToken = $('meta[name="csrf-token"]').attr("content");
        $.ajax({
            statusCode: {
                302: function() {
                    layer.alert('登录信息已过期，请重新登录',{icon: 1,closeBtn:0},function(index){
                        layer.close(index);
                        window.top.location.href='/marriage/admin/web/index.php/';
                        return false;
                    });
                }
            }
        });
        page = $('.pagination').find('.active').find('a').text();
        layer.confirm('确认删除该用户的信息？',{icon: 0, title:'提示'},function(index){
            layer.close(index);
            ShowLoad();
            $.post('/marriage/admin/web/index.php/user/del',{
                'mi_id':mi_id.text(),
                '_marriage-admin':csrfToken
            },function(data){
                if(data.status == '302'){
                    layer.alert('登录信息已过期，请重新登录',{icon: 0,closeBtn:0},function(){
                        window.top.location.href='/marriage/admin/web/index.php/';
                    });
                    return false;
                }else if(data.status == '200'){
                    searchUser(page);
                    ShowMessage(data.status,data.message);
                    return true;
                }else{
                    ShowMessage(data.status,data.message);
                    return false;
                }
            },'json');
        });
    });
    $("tr").find('#user_recover').click(function(){
        mi_id = $(this).parents('tr').find('#mi_id');
        csrfToken = $('meta[name="csrf-token"]').attr("content");
        $.ajax({
            statusCode: {
                302: function() {
                    layer.alert('登录信息已过期，请重新登录',{icon: 1,closeBtn:0},function(index){
                        layer.close(index);
                        window.top.location.href='/marriage/admin/web/index.php/';
                        return false;
                    });
                }
            }
        });
        page = $('.pagination').find('.active').find('a').text();
        layer.confirm('确认恢复该用户的信息？',{icon: 0, title:'提示'},function(index){
            layer.close(index);
            ShowLoad();
            $.post('/marriage/admin/web/index.php/user/recover',{
                'mi_id':mi_id.text(),
                '_marriage-admin':csrfToken
            },function(data){
                if(data.status == '302'){
                    layer.alert('登录信息已过期，请重新登录',{icon: 0,closeBtn:0},function(){
                        window.top.location.href='/marriage/admin/web/index.php/';
                    });
                    return false;
                }else if(data.status == '200'){
                    searchUser(page);
                    ShowMessage(data.status,data.message);
                    return true;
                }else{
                    ShowMessage(data.status,data.message);
                    return false;
                }
            },'json');
        });
    });
    $('#myDialog').on('hidden.bs.modal',function(event){
        $("#user_info")[0].reset();//重置表单
    });
    $('#myDialog').on('show.bs.modal',function(event){
        var mydate = new Date();
        var year = mydate.getFullYear(); //获取完整的年份(4位,1970-????)
        var mon = mydate.getMonth(); //获取当前月份(0-11,0代表1月),
        if(mon<9){
            mon = '0'+(mon+1);
        }else{
            mon = mon+1
        }
        $('#userinfo-mi_birth').val( year+'年'+mon+'月');
    });
    $("#user_info").on('beforeSubmit',function(e){
        $('#userdetail-md_location').attr('value','');
        info_privince = $('#info_privince option:selected').text();
        info_city = $('#info_city option:selected').text();
        extra_privince = $('#extra_privince option:selected').text();
        extra_city = $('#extra_city option:selected').text();
        extra_district = $('#extra_district option:selected').text();
        $('#userinfo-mi_root').attr('value',info_privince+';'+info_city);
        $('#userextra-me_postion').attr('value',extra_privince+';'+extra_city+';'+extra_district);
        md_marry = $('#userdetail-md_marry').val();
        md_child = $('input:radio[name="UserDetail[md_child]"]:checked').val();
        md_despid = $('#userdetail-md_despid').val();
        child_belong = $('#userdetail-md_child_belong').val();
        if($('#md_isowner').is(':checked')){
            detail_privince = $('#detail_privince option:selected').val();
            detail_city = $('#detail_city option:selected').val();
            detail_district = $('#detail_district option:selected').val();
            md_house_area = $('#userdetail-md_house_area').val();
            if((detail_privince=='0'||detail_privince=='')||(detail_city=='0'||detail_city=='')||(detail_district=='0'||detail_district=='')){
                layer.alert('请选择房屋地址所在',{icon: 0,closeBtn:0},function(index){
                    layer.close(index);
                });
                return false;
            }
            $('#userdetail-md_location').attr('value',
                $('#detail_privince option:selected').text()+';'+
                $('#detail_city option:selected').text()+';'+
                $('#detail_district option:selected').text());
        }
        $.ajax({
            statusCode: {
                302: function() {
                    layer.alert('登录信息已过期，请重新登录',{icon: 1,closeBtn:0},function(){
                        window.top.location.href='/marriage/admin/web/index.php/';
                    });
                    return false;
                }
            },
            url: $(this).attr('action'),
            type: $(this).attr('method'),
            data: $(this).serialize(),
            beforeSend: function () {
                ShowLoad();
            },
            complete: function () {
                layer.closeAll('loading');
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                layer.alert('发生错误', {icon: 5});
                return false;
            },
            success: function (data) {
                ShowMessage(data.status,data.message);
                if(data.status == '302'){
                    layer.alert('登录信息已过期，请重新登录',{icon: 0,closeBtn:0},function(){
                        window.top.location.href='/marriage/admin/web/index.php/';
                    });
                    return false;
                }else if(data.status == '200'){
                    location.href='/marriage/admin/web/index.php/user/view?id='+data.data;
                    return false;
                }else{
                    return false;
                }
            }
        });
        return false;
    });
});

function clearNoNum(obj)
{
    //先把非数字的都替换掉，除了数字和.
    obj.value = obj.value.replace(/[^\d.]/g,"");
    //必须保证第一个为数字而不是.
    obj.value = obj.value.replace(/^\./g,"");
    //保证只有出现一个.而没有多个.
    obj.value = obj.value.replace(/\.{2,}/g,".");
    //保证.只出现一次，而不能出现两次以上
    obj.value = obj.value.replace(".","$#$").replace(/\./g,"").replace("$#$",".");
}
function searchUser(page){
    page!=null? $("[name='user_page']").val(page):null;
    mi_name = $('#searchName').val();
    me_phone = $('#searchPhone').val();
    me_qq = $('#searchQQ').val();
    mi_cardid = $('#searchCard').val();
    minage = $('#searchminage').val();
    maxage = $('#searchmaxage').val();
    md_isowner = $('#searchIsowner').is(':checked') ? '2':'';
    md_hascar = $('#searchHascar').is(':checked') ? '2':'';
    mi_sex = $('[name="sex"]').val();
    province = $('[name="province"]').val();
    city = $('[name="city"]').val();
    district = $('[name="district"]').val();
    mi_edu = $('[name="edu"]').val();
    csrfToken = $('meta[name="csrf-token"]').attr("content");
    if(minage>maxage&&minage!=''&&maxage!=''){
        layer.alert('最小年龄不能超过最大年龄');
        return false;
    }
    var searchArr = {};
    var fieldArr = {};
    searchArr['mi_name']=mi_name;
    searchArr['mi_cardid']=mi_cardid;
    searchArr['mi_sex']=mi_sex;
    searchArr['me_phone']=me_phone;
    searchArr['me_qq']=me_qq;
    fieldArr['md_isowner']=md_isowner;
    fieldArr['md_hascar']=md_hascar;
    fieldArr['mi_edu']=mi_edu;
    fieldArr['minage']=minage;
    fieldArr['maxage']=maxage;
    fieldArr['province']=province;
    fieldArr['city']=city;
    fieldArr['district']=district;
    $.ajax({
        statusCode: {
            302: function() {
                layer.alert('登录信息已过期，请重新登录',{icon: 1,closeBtn:0},function(){
                    window.top.location.href='/marriage/admin/web/index.php/';
                });
                return false;
            }
        },
        url: $(".fixed-sidebar").data("id"),
        data:{"page":page,"search":searchArr,"field":fieldArr,"_marriage-admin":csrfToken},
        beforeSend: function () {
            ShowLoad();
        },
        complete: function () {
            layer.closeAll('loading');
        },
        error: function (XMLHttpRequest, textStatus, errorThrown) {
            layer.alert('发生错误', {icon: 5});
            return false;
        },
        success: function (data) {
            layer.closeAll('loading');
            $('.fixed-sidebar').html(data);
            return false;
        }
    });
}

var nameSuggest=$("#searchName").bsSuggest({
    url: '/marriage/admin/web/index.php/user/search?key=mi_name&table=mm_user_info&val=',                      //请求数据的 URL 地址
    getDataMethod: "url",           //获取数据的方式，url：一直从url请求；data：从 options.data 获取；firstByUrl：第一次从Url获取全部数据，之后从options.data获取
    ignorecase: false,              //不忽略大小写
    showBtn: false,                  //是否显示下拉按钮
    allowNoKeyword: false,           //是否允许无关键字时请求数据
    multiWord: false,               //以分隔符号分割的多关键字支持
    processData: function(json){
        var i,len,data={value:[]};
        if(!json||!json.data||json.data.length==0){
            return false
        }
        console.log(json);
        len=json.data.length;
        for(i=0;i<len;i++){
            data.value.push(
                {
                    "name":json.data[i]
                }
            )}
        console.log(data);
        return data
    },       //格式化数据的方法，返回数据格式参考 data 参数
    autoMinWidth: true,            //是否自动最小宽度，设为 false 则最小宽度不小于输入框宽度
    listAlign: "left",              //提示列表对齐位置，left/right/auto
    inputWarnColor: "rgba(255,0,0,.1)", //输入框内容不是下拉列表选择时的警告色
    listStyle: {
        "padding-top":0, "max-height": "375px", "max-width": "200px","margin-left":"68px","min-width": "179px",
        "transition": "0.5s", "-webkit-transition": "0.5s", "-moz-transition": "0.5s", "-o-transition": "0.5s"
    },                              //列表的样式控制
    listHoverStyle: 'background: #07d; color:#fff', //提示框列表鼠标悬浮的样式
    listHoverCSS: "jhover"         //提示框列表鼠标悬浮的样式名称
}).on("onDataRequestSuccess",function(e,result){
    console.log("onDataRequestSuccess: ",result)
}).on("onSetSelectValue",function(e,result){
    console.log('onSetSelectValue: ', result);
}).on("keydown",function(e){
    if (e.keyCode == "13") {
        searchUser(1);
    }
}).on("blur",function(){
    searchUser(1);
});

var phoneSuggest=$("#searchPhone").bsSuggest({
    url: '/marriage/admin/web/index.php/user/search?key=me_phone&table=mm_user_extra&val=',                      //请求数据的 URL 地址
    getDataMethod: "url",           //获取数据的方式，url：一直从url请求；data：从 options.data 获取；firstByUrl：第一次从Url获取全部数据，之后从options.data获取
    ignorecase: false,              //不忽略大小写
    showBtn: false,                  //是否显示下拉按钮
    allowNoKeyword: false,           //是否允许无关键字时请求数据
    multiWord: false,               //以分隔符号分割的多关键字支持
    processData: function(json){
        var i,len,data={value:[]};
        if(!json||!json.data||json.data.length==0){
            return false
        }
        console.log(json);
        len=json.data.length;
        for(i=0;i<len;i++){
            data.value.push(
                {
                    "phone":json.data[i]
                }
            )}
        console.log(data);
        return data
    },       //格式化数据的方法，返回数据格式参考 data 参数
    autoMinWidth: true,            //是否自动最小宽度，设为 false 则最小宽度不小于输入框宽度
    listAlign: "left",              //提示列表对齐位置，left/right/auto
    inputWarnColor: "rgba(255,0,0,.1)", //输入框内容不是下拉列表选择时的警告色
    listStyle: {
        "padding-top":0, "max-height": "375px", "max-width": "200px","margin-left":"68px","min-width": "179px",
        "transition": "0.5s", "-webkit-transition": "0.5s", "-moz-transition": "0.5s", "-o-transition": "0.5s"
    },                              //列表的样式控制
    listHoverStyle: 'background: #07d; color:#fff', //提示框列表鼠标悬浮的样式
    listHoverCSS: "jhover"         //提示框列表鼠标悬浮的样式名称
}).on("onDataRequestSuccess",function(e,result){
    console.log("onDataRequestSuccess: ",result)
}).on("onSetSelectValue",function(e,result){
    console.log('onSetSelectValue: ', result);
}).on("keydown",function(e){
    if (e.keyCode == "13") {
        searchUser(1);
    }
}).on("blur",function(){
    searchUser(1);
});

var qqSuggest=$("#searchQQ").bsSuggest({
    url: '/marriage/admin/web/index.php/user/search?key=me_qq&table=mm_user_extra&val=',                      //请求数据的 URL 地址
    getDataMethod: "url",           //获取数据的方式，url：一直从url请求；data：从 options.data 获取；firstByUrl：第一次从Url获取全部数据，之后从options.data获取
    ignorecase: false,              //不忽略大小写
    showBtn: false,                  //是否显示下拉按钮
    allowNoKeyword: false,           //是否允许无关键字时请求数据
    multiWord: false,               //以分隔符号分割的多关键字支持
    processData: function(json){
        var i,len,data={value:[]};
        if(!json||!json.data||json.data.length==0){
            return false
        }
        console.log(json);
        len=json.data.length;
        for(i=0;i<len;i++){
            data.value.push(
                {
                    "qq":json.data[i]
                }
            )}
        console.log(data);
        return data
    },       //格式化数据的方法，返回数据格式参考 data 参数
    autoMinWidth: true,            //是否自动最小宽度，设为 false 则最小宽度不小于输入框宽度
    listAlign: "left",              //提示列表对齐位置，left/right/auto
    inputWarnColor: "rgba(255,0,0,.1)", //输入框内容不是下拉列表选择时的警告色
    listStyle: {
        "padding-top":0, "max-height": "375px", "max-width": "200px","margin-left":"62px","min-width": "185px",
        "transition": "0.5s", "-webkit-transition": "0.5s", "-moz-transition": "0.5s", "-o-transition": "0.5s"
    },                              //列表的样式控制
    listHoverStyle: 'background: #07d; color:#fff', //提示框列表鼠标悬浮的样式
    listHoverCSS: "jhover"         //提示框列表鼠标悬浮的样式名称
}).on("onDataRequestSuccess",function(e,result){
    console.log("onDataRequestSuccess: ",result)
}).on("onSetSelectValue",function(e,result){
    console.log('onSetSelectValue: ', result);
}).on("keydown",function(e){
    if (e.keyCode == "13") {
        searchUser(1);
    }
}).on("blur",function(){
    searchUser(1);
});

var cardSuggest=$("#searchCard").bsSuggest({
    url: '/marriage/admin/web/index.php/user/search?key=mi_cardid&table=mm_user_info&val=',                      //请求数据的 URL 地址
    getDataMethod: "url",           //获取数据的方式，url：一直从url请求；data：从 options.data 获取；firstByUrl：第一次从Url获取全部数据，之后从options.data获取
    ignorecase: false,              //不忽略大小写
    showBtn: false,                  //是否显示下拉按钮
    allowNoKeyword: false,           //是否允许无关键字时请求数据
    multiWord: false,               //以分隔符号分割的多关键字支持
    processData: function(json){
        var i,len,data={value:[]};
        if(!json||!json.data||json.data.length==0){
            return false
        }
        console.log(json);
        len=json.data.length;
        for(i=0;i<len;i++){
            data.value.push(
                {
                    "card":json.data[i]
                }
            )}
        console.log(data);
        return data
    },       //格式化数据的方法，返回数据格式参考 data 参数
    autoMinWidth: true,            //是否自动最小宽度，设为 false 则最小宽度不小于输入框宽度
    listAlign: "left",              //提示列表对齐位置，left/right/auto
    inputWarnColor: "rgba(255,0,0,.1)", //输入框内容不是下拉列表选择时的警告色
    listStyle: {
        "padding-top":0, "max-height": "375px", "max-width": "200px","margin-left":"62px","min-width": "185px",
        "transition": "0.5s", "-webkit-transition": "0.5s", "-moz-transition": "0.5s", "-o-transition": "0.5s"
    },                              //列表的样式控制
    listHoverStyle: 'background: #07d; color:#fff', //提示框列表鼠标悬浮的样式
    listHoverCSS: "jhover"         //提示框列表鼠标悬浮的样式名称
}).on("onDataRequestSuccess",function(e,result){
    console.log("onDataRequestSuccess: ",result)
}).on("onSetSelectValue",function(e,result){
    console.log('onSetSelectValue: ', result);
}).on("keydown",function(e){
    if (e.keyCode == "13") {
        searchUser(1);
    }
}).on("blur",function(){
    searchUser(1);
});

function goPage(obj){
    var page=$(obj).data('page')+1;
    searchUser(page);
    return false;
}